package luogu.editor;

import java.util.Scanner;

public class P8772 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        System.out.println(func1(a));
    }
    // 暴力
    long func1(long[] a){
        long sum=0;
        for (int i = 0; i < a.length - 1;i++){
            for (int j = i+1; j < a.length; j++) {
                sum += a[j]*a[i];
            }
        }
        return sum;
    }
    // 前缀和
    long func2(long[] a){
        long sum=0;
        // 计算前缀和
        long[] prefixSum = new long[a.length + 1];
        for (int i = 1; i <= a.length; i++) {
            prefixSum[i] = prefixSum[i - 1] + a[i - 1];
        }
        // 计算两两乘积之和
        for (int i = 0; i < a.length - 1; i++) {
            sum += a[i] * (prefixSum[a.length] - prefixSum[i + 1]);
        }
        return sum;
    }
    // 累计和
    long func3(long[] a){
        long sumSoFar = 0;
        long totalSum = 0;
        
        // 遍历数组
        for (int i = 0; i < a.length; i++) {
            // 将当前元素与之前所有元素的乘积之和加到totalSum中
            totalSum += a[i] * sumSoFar;
            // 更新sumSoFar
            sumSoFar += a[i];
        }
        return totalSum;
    }
}
